var MenuModel = require("./js/menu");

module.exports = {

	render: function(req, res, next) {
		res.render('admin/menus', {
			layout: 'admin',
			cdActive: 'active'
		});
	},
	add: function(req, res, next) {

		var menu = new MenuModel(req.body.id, req.body.name, req.body.url, req.body.index, req.body.remark);
		menu.add(function(data) {
			res.json(data);
		});
	},
	del: function(req, res, next) {

		var menu = new MenuModel();
		menu.del(req.body.id, function(data) {
			res.json(data);
		});
	},
	edit: function(req, res, next) {

		var menu = new MenuModel(req.body.id, req.body.name, req.body.url, req.body.index, req.body.remark);
		menu.edit(req.body.id, function(data) {
			res.json(data);
		});
	}
};